package com.newasia.management.constants;

/**
 * 腾讯课堂搜索【咕泡学院】
 * 官网：www.gupaoedu.com
 * 风骚的Mic 老师
 * create-date: 2019/7/23-16:45
 * user-service统一错误码为  004
 */
public enum ManagementRetCode {
    // 系统公用
    SUCCESS                             ("000000", "成功"),

    REQUISITE_PARAMETER_NOT_EXIST       ("009073", "必要的参数不能为空"),
    REQUISITE_PARAMETER_ERROR            ("009073", "必要的参数错误"),
    EXIST_ITEM_CAT_ERROR                ("009011", "存在子分类"),
    EXIST_ITEM_Good_ERROR                ("009012", "存在子商品"),
    EXIST_ITEM_CAT_NAME               ("009013", "存在分类名称"),
    EXIST_ITEM_BRAND_NAME               ("009014", "存在品牌名称"),
    EXIST_ITEM_BRAND_GOODS               ("009015", "存在该品牌商品"),
    EXIST_ITEM_SPEC              ("009016", "存在同名子项"),
    NOT_EXIST_ITEM_SPEC              ("009017", "不存在父项规格样式"),
    EXIST_ITEM_SPU             ("009018", "已存在该商品"),
    NOT_EXIST_ITEM_SPU             ("009019", "不存在该商品"),
    NEED_ONE_ITEM         ("009020", "至少选中1个子项"),
    CAN_NOT_DELETE              ("009021", "重要参数，无法删除"),
    LIMIT_FIVE         ("009022", "最多只能有5个"),
    LIMIT_FOUR         ("009022", "最多只能有4个"),
    LIMIT_THREE        ("009022", "只能三层"),
    ALREADY_FIRST       ("009022", "已经是第一层,不能再添加firstId"),
    NOT_EXIST         ("009023", "不存在"),
    NOT_EXIST_AGENT     ("009024", "不存在该代理等级"),
    AT_LEAST_ONE_AGENT     ("009025", "至少要选择一个代理商"),
    CHOOSE_FIRST    ("009026", "请选择最顶层分类"),
    CHOOSE_THREE_CAT    ("009026", "请选择有三层的分类"),
    CHOOSE_THREE    ("009026", "请选择最底层分类"),
    CANT_DELETE         ("009027", "该接口无法操作轮播图和活动的组"),

    NOT_UP("009026", "该子商品没有上架，或已删除"),
    EXIST_ITEM_NAV             ("009011", "存在子项导航，请先删除"),




    ONLY_TOP_CAN     ("009026", "只能选择最顶层分类"),
    NOT_TYPE_ONE     ("009027", "父菜单 type不是其他链接类型"),

    USERORPASSWORD_ERRROR               ("009001","用户名或密码不正确"),
    TOKEN_VALID_FAILED                  ("009002","token校验失败"),
    USERNAME_ALREADY_EXISTS             ("009003","用户名已存在"),
    USER_REGISTER_FAILED                ("009004","注册失败，请联系管理员"),
    KAPTCHA_CODE_ERROR                   ("009005","验证码不正确"),
    USER_FROZEN                           ("009006","用户被冻结"),
    USERNAME_NOT_EXIST                   ("009007","用户名不存在"),
    ROLE_NOT_EXIST                          ("009008","该角色不存在"),
    USER_UPDATE_FAILED                      ("009009","更新失败，请联系管理员"),
    ROLE_COMMENT_FAILED                      ("009010","角色关联失败，请联系管理员"),
    ROLENAME_ALREADY_EXISTS              ("0090011","角色名已存在"),
    SYSTEM_MENU_CANNOT_DELETE            ("0090012","系统权限不可删除"),
    SYSTEM_MENU_CANNOT_REVISE            ("0090013","系统权限不可修改"),
    SYSTEM_MENU_ERROR                      ("0090014","该用户没有此权限"),

    ROLE_INSERT_ERROR                   ("009020","权限注入错误"),
    ROLE_UPDATE_ERROR                   ("009021","权限更新错误"),
    ROLE_REPEAT_ERROR                   ("009022","权限重复错误"),

    REQUEST_FORMAT_ILLEGAL              ("009060", "请求数据格式非法"),
    REQUEST_IP_ILLEGAL                  ("009061", "请求IP非法"),
    REQUEST_CHECK_FAILURE               ("009062", "请求数据校验失败"),
    DATA_NOT_EXIST                      ("009070", "数据不存在"),
    DATA_REPEATED                       ("009071", "数据重复"),
    REQUEST_DATA_NOT_EXIST              ("009072", "传入对象不能为空"),
    REQUEST_DATA_ERROR                  ("009074", "必要的参数不正确"),
    PERMISSION_DENIED                   ("009091", "权限不足"),
    REQUEST_CHARACTERS_ILLEGAL          ("009092", "请求数据有非法字符"),

    DB_EXCEPTION                        ("109097", "数据库异常"),
    SYSTEM_TIMEOUT                      ("109098", "系统超时"),
    SYSTEM_ERROR                        ("109099", "系统错误");



    private String code;
    private String message;

    ManagementRetCode(String code, String message) {
        this.code = code;
        this.message = message;
    }

    /**
     * Getter method for property <tt>code</tt>.
     *
     * @return property value of code
     */
    public String getCode() {
        return code;
    }

    /**
     * Setter method for property <tt>code</tt>.
     *
     * @param code value to be assigned to property code
     */
    public void setCode(String code) {
        this.code = code;
    }

    /**
     * Getter method for property <tt>message</tt>.
     *
     * @return property value of message
     */
    public String getMessage() {
        return message;
    }

    /**
     * Setter method for property <tt>message</tt>.
     *
     * @param message value to be assigned to property message
     */
    public void setMessage(String message) {
        this.message = message;
    }

    public static String getMessage(String code) {
        for (ManagementRetCode s : ManagementRetCode.values()) {
            if (null == code)
                break;
            if (s.code.equals(code)) {
                return s.message;
            }
        }
        return null;
    }
}
